home *** CD-ROM | disk | FTP | other *** search
- This diskette contains version 2.1 of the Small-C compiler for
- use with MS/PC-DOS 2.1 or later -- It makes use of MASM and LINK
- and includes a full library of UNIX/C functions. The following
- files are included:
-
- READ.ME This documentation.
- CC.EXE Executable Small-C compiler.
- AR.EXE Executable archive maintainer.
- CLIB.LIB Small-C relocatable library for use with LINK.
- STDIO.H Standard header file for all compiles.
- AR.C Archive maintainer source.
- CC.ARC Small-C compiler source code archive.
- CLIB.ARC Small-C library source code archive.
-
- This software is fully documented in "The Small-C Handbook" by
- James E. Hendrix (Reston Publishing Co., Reston, VA, March
- 1983). The Handbook was writtten for the CP/M version of
- Small-C, however, an MS/PC-DOS specific addendum is available.
- Copies of these can be obtained from Dr.Dobb's Journal, 2464
- Embarcadero Way, Palo Alto, CA 94303.
-
- The compiler takes in a subset of the syntax for the full C
- language, and generates Intel assembly language mnemonics. It
- supports only integer and character data types. Arrays are
- limited to one dimension. It does not support arrays of
- pointers, structures, or unions. Also missing are sizeof,
- casts, #if expr, #undef, and #line. External functions are
- automatically declared, but external variables must be declared
- explicitly. Functions always return integer values. Globals
- may be initialized using the = syntax, but locals cannot.
- Locals are always automatic, and the specifiers auto, static,
- extern, register, and typedef are not accepted at the local
- level. Only extern is accepted at the global level. Character
- variables are expanded with sign-extension when they appear in
- expressions; character constants are not. Avoid using names
- which begin with the underscore character since they are used by
- system functions in the library. Examples of invoking the
- compiler follow:
-
- CC compile console input
- giving console output
-
- CC <FILE1 -L1 -P compile FILE1 giving console
- output, list the source as
- comments in the output, and
- pause on errors
-
- CC <FILE1 >FILE2 -M compile FILE1 giving FILE2
- and monitor progress by
- listing function headers on
- the console
-
- CC FILE1 FILE2 >FILE3 compile FILE1 then FILE2 into
- a single program in FILE3
-
- CC FILE1 compile FILE1 (default ext. C)
- giving FILE1 (ext. ASM)
-
- CC FILE1 FILE2 compile FILE1 then FILE2 (default
- ext. C) giving FILE1 (ext. ASM)
-
- Any number of files may be concatenated as input by listing them
- in the command line; in that case stdin is not used. Standard
- DOS file specifications, including logical devices, are
- accepted. The listing switch has two forms:
-
-
- -L1 lists on stdout (with output) as comments
- -L2 lists on stderr (always the console)
-
- Pressing control-S makes the compiler pause until another key is
- pressed, and control-C aborts the run. Enter a CR to resume
- execution after a pause because of a compile error. If input is
- from the keyboard, control-Z indicates end-of-file, control-X
- rubs out the pending line, and BS rubs out the previous
- character. If the compiler aborts with the letter M on the
- screen, there is insufficient memory to run it; however, a 64K
- system should suffice.
-
- The easiest way to compile a program is simply:
- CC MYPROG.C -M -A -P
-
- This will result in a file called MYPROG.ASM. You must still
- assemble it and link it to the function library using MASM and
- LINK from your DOS disk:
-
- MASM MYPROG,MYPROG,NUL,NUL to assemble it, then:
-
- LINK MYPROG, MYPROG, NUL, CLIB.LIB to link it.
-
- Comments in the front of AR.C describe the operation of the
- archive maintainer AR.COM. To extract all of the modules out of
- the archives, put AR.EXE and CC.ARC (or CLIB.ARC) on a new disk
- and enter the commands:
- AR -X CC.ARC
- AR -X CLIB.ARC
-
- The function fflush() has been droppped from this implementation
- of Small-C. Since all I/O is through the new (with DOS 2.0)
- "file handle" facility and no provision is made for forcing DOS
- to flush its buffers, this function could not be supported.
-
- The ternary operator (?:) is supported.
-
- Octal and hexadecimal constants are supported. Note that the
- subscripts in The Small-C Handbook on page 160 have leading
- zeroes. This has been corrected in your source.
-
- The code generating logic in the compiler has been improved over
- that given in the Handbook.
-
- - auxbuf (fd, size) int fd, size;
-
- This Small-C function allocates an auxiliary buffer of size
- bytes for fd. It returns zero on success and ERR on failure.
- Fd need not be open; however, for compatibility with the CP/M
- implementation, you should call auxbuf() only on an open fd.
- Size must be greater than zero and less than the amount of
- free memory. If fd is a device, the buffer is allocated but
- ignored. This implementation of Small-C uses "file handle"
- calls to DOS; it reads and writes in chunks the size of the
- auxiliary buffer. Extra buffering is useful in reducing disk
- head movement or drive switching during sequential operations.
- Once an auxiliary buffer is allocated it sticks for the
- duration of program execution, even if fd is closed. Calling
- this function a second time for the same fd is allowed,
- however, the original buffer continues to occupy space in
- allocated memory. Alternating read and write operations and
- performing seeks with auxiliary buffering is also allowed, but
- is also incompatible with CP/M. Ungetc() will operate
- normally. Ordinarily, it is counter productive to allocate
- auxiliary buffers to both input and output files.
-
- - bseek(fd, offset, base) int fd, offset[], base;
-
- This Small-C function positions the DOS file pointer for fd to
- the byte indicated by the double length integer offset.
- Offset must be given as the address of an array of two
- interers such that offset[0] is the low order half and
- offset[1] is the high order half. Base determines the base
- location from which the offset is applied. It may have any of
- the following values:
-
- BASE OFFSET-RELATIVE-TO
- 0 beginning of file
- 1 current byte in file
- 2 end of file (minus offset)
-
- Bseek() returns NULL on success, otherwise EOF. It works like
- the UNIX function fseek() except that the offset is an address
- instead of the actual value. This is necessary since Small-C
- does not presently support long variables.
-
-
- - btell(fd, offset) int fd, offset[];
-
- This Small-C function tells the offset to the current byte in
- the file indicated by fd. The current byte is the next one
- that will be read from or written to the file. No account of
- ungetc() calls is taken. Offset is a double length integer
- and must be specified as the address of an array of two
- interers such that offset[0] is the low order half and
- offset[1] is the high order half. The array at offset
- receives the offset value of the current byte in the file.
- Btell returns NULL on success, otherwise ERR.
-
-
- - ctellc(fd) int fd;
-
- This Small-C function returns the offset (0-127) to the
- current byte in the current record for fd. The current byte
- is the next one that will be read from or written to the file.
- No account of ungetc() calls is taken.
-
-
- - cseekc(fd, offset) int fd, offset;
-
- This Small-C function positions fd on the character indicated
- by offset within current 128-byte record. The current byte
- must be on a record boundary. Used in combination with
- cseek() this function allows you to seek to a given byte in a
- file by tracking file positions in two parts, the record
- offset and the byte offset within the record. Cseekc()
- returns NULL on success, otherwise EOF.
-
-
- - pad (str, ch, n) char *str, ch; int n;
-
- This Small-C function fills the string at str with n
- occurrences of the character ch.
-
-
- - rename (old, new) char *old, *new;
-
- This Small-C function changes the name of the file specified
- by old to the name indicated by new. It returns NULL on
- success, otherwise ERR.
-
-